/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.model.item.etcitem.action;

import static com.lineage.server.model.skill.L1SkillId.STATUS_HOLY_MITHRIL_POWDER;
import static com.lineage.server.model.skill.L1SkillId.STATUS_HOLY_WATER;
import static com.lineage.server.model.skill.L1SkillId.STATUS_HOLY_WATER_OF_EVA;

import com.lineage.server.PacketCreate;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.item.ItemExecutor;
import com.lineage.server.packetserver.S_ServerMessage;
import com.lineage.server.packetserver.S_SkillSound;

/**
 * Class <code>PotionHolyWater</code> 圣水 - 41315.
 * 
 * @author jrwz
 * @version 2012-6-24上午07:16:30
 * @see com.lineage.server.model.item.etcitem.action
 * @since JDK1.7
 */
public final class PotionHolyWater extends ItemExecutor {

    /**
     * 取得实例.
     * 
     * @return 实例
     */
    public static ItemExecutor get() {
        return new PotionHolyWater();
    }

    /** 圣水 - 41315. */
    private PotionHolyWater() {
    }

    @Override
    public void execute(final L1PcInstance pc, final L1ItemInstance useItem,
            final int readC1, final int readC2, final int targetId,
            final int targetX, final int targetY) {
        // 伊娃圣水状态
        if (pc.hasSkillEffect(STATUS_HOLY_WATER_OF_EVA)) {
            PacketCreate.get().sendSinglePackets(pc, "没有任何事情发生");
            return;
        }

        // 删除神圣的米索莉粉状态
        if (pc.hasSkillEffect(STATUS_HOLY_MITHRIL_POWDER)) {
            pc.removeSkillEffect(STATUS_HOLY_MITHRIL_POWDER);
        }

        pc.setSkillEffect(STATUS_HOLY_WATER, 900 * 1000);
        pc.sendPackets(new S_SkillSound(pc.getId(), 190));
        pc.broadcastPacket(new S_SkillSound(pc.getId(), 190));
        pc.sendPackets(new S_ServerMessage(1141)); // 你得到可以攻击充满怨恨的幽灵的力量。
        pc.getInventory().removeItem(useItem, 1);
    }
}
